package com.tony.study.thread;

/**
 * Created with IntelliJ IDEA.
 *
 * @Title: JoinDemo01
 * @Auther: 皮蛋布丁
 * @Date: 2021/10/31/17:06
 * @Description: 测试join方法，想象为插队
 */
public class JoinDemo01 implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println("线程vip来了"+i);
        }
    }

    public static void main(String[] args) throws InterruptedException {
        //启动线程
        JoinDemo01 join = new JoinDemo01();
        Thread thread = new Thread(join);
        thread.start();
        //主线程
        for (int i = 0; i < 1000; i++) {
            if (i == 200) {
                thread.join();  //插队
            }
            System.out.println("main"+i);
        }
    }
}
